<% add_decidim_page_title(t(".title")) %>
<div class="item_show__header">
  <h1 class="item_show__header-title">
    <div>
      <%= link_to "#{t("title", scope: "decidim.admin.moderations.index")} > ", moderations_path %>
      <%= t(".title") %>
    </div>
  </h1>
</div>

<div class="card-section moderation-details">
  <%= cell("decidim/announcement", t(".callout_html", icon: icon("flag-line")), callout_class: "warning") %>
  <dl>
    <dt><%= t("models.moderation.fields.reported_content_url", scope: "decidim.moderations") %></dt>
    <% if (reportable_url = moderation.reportable.reported_content_url) %>
      <dd><%= link_to moderation.reportable.reported_content_url, reportable_url, target: "_blank" %></dd>
    <% else %>
      <dd><%= t("models.moderation.fields.deleted_resource", scope: "decidim.moderations") %></dd>
    <% end %>

    <dt><%= t("models.moderation.fields.reportable_id", scope: "decidim.moderations") %></dt>
    <dd><%= moderation.reportable.id %></dd>

    <% if translatable_resource?(moderation.reportable) %>
      <dt><%= t(".content_original_language") %></dt>
      <dd><%= locale_name moderation.reportable.content_original_language %> </dd>
    <% end %>

    <dt>
      <%= t(".reported_content") %>
      <% if translatable_resource?(moderation.reportable) %>
        <button
          class="toggle-content"
          data-see-original-button-label="<%= t(".see_original") %>"
          data-see-current-button-label="<%= t(".see_current") %>">
          <%= t(".see_original") %>
        </button>
      <% end %>
    </dt>
    <dd class="reported-content">
      <div>
        <%= reported_content_for moderation.reportable %>
      </div>
      <% if translatable_resource?(moderation.reportable) %>
        <div class="original">
          <%= reported_content_for moderation.reportable, locale: moderation.reportable.content_original_language %>
        </div>
      <% end %>
    </dd>

    <dt><%= t(".author") %></dt>
    <dd>
      <%= reportable_author_name(moderation.reportable) %>
    </dd>

    <dt><%= t("models.moderation.fields.reportable_type", scope: "decidim.moderations") %></dt>
    <dd><%= moderation.reportable.class.name.demodulize %></dd>

    <dt><%= t("models.moderation.fields.created_at", scope: "decidim.moderations") %></dt>
    <dd><%= l(moderation.created_at, format: :decidim_short) %></dd>

    <dt><%= t(".participatory_space") %></dt>
    <dd><%= translated_attribute moderation.participatory_space.title %></dd>
  </dl>
</div>
<div class="table-scroll">
  <table class="table-list">
    <thead>
    <tr>
      <th><%= t("models.report.fields.reason", scope: "decidim.moderations") %></th>
      <th><%= t("models.report.fields.locale", scope: "decidim.moderations") %></th>
      <th><%= t("models.report.fields.details", scope: "decidim.moderations") %></th>
      <th><%= t("actions.title", scope: "decidim.moderations") %></th>
    </tr>
    </thead>
    <tbody>
    <% reports.each do |report| %>
      <tr data-id="<%= report.id %>">
        <td><%= t("decidim.admin.moderations.report.reasons.#{report.reason}") %></td>
        <td><%= report.locale.present? ? locale_name(report.locale) : "" %></td>
        <td><%= report.details&.truncate(250) %></td>
        <td>
          <%= icon_link_to "fullscreen-line",
                           moderation_report_path(moderation_id: moderation, id: report.id),
                           t("actions.expand", scope: "decidim.moderations") %>
        </td>
      </tr>
    <% end %>
    </tbody>
  </table>
</div>
<div class="item__edit-sticky">
  <div class="item__edit-sticky-container">
    <% if !moderation.reportable.hidden? && allowed_to?(:unreport, authorization_scope) %>
      <%= link_to t("actions.unreport", scope: "decidim.moderations"), unreport_moderation_path(id: moderation), method: :put, class: "button button__sm button__secondary" %>
    <% end %>
    <% if !moderation.reportable.hidden? && allowed_to?(:hide, authorization_scope) %>
      <%= link_to t("actions.hide", scope: "decidim.moderations"), hide_moderation_path(id: moderation), method: :put, class: "button button__sm button__secondary alert" %>
    <% end %>
    <% if moderation.reportable.hidden? && allowed_to?(:unhide, authorization_scope) %>
      <%= link_to t("actions.unhide", scope: "decidim.moderations"), unhide_moderation_path(id: moderation), method: :put, class: "button button__sm button__secondary alert" %>
    <% end %>
  </div>
</div>
